package net.sansi.v3correctserver.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import net.sansi.v3correctserver.constenum.AppHelper;
import net.sansi.v3correctserver.dto.R;
import net.sansi.v3correctserver.entity.space.CorrectCnf;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Fang
 * create time : 2025/1/22
 * IDE : IntelliJ IDEA
 */

@Api(tags = "矫正配置接口")
@Slf4j
@RestController
@RequestMapping("/correct-cnf")
public class CorrectCnfController {

    /**
     * 查询配置
     *
     * @return 配置
     */
    @ApiOperation("查询配置")
    @GetMapping("/query")
    public R<CorrectCnf> query() {
        return R.data(AppHelper.projectSpace().getCorrectCnf());
    }

    /**
     * 更新配置
     *
     * @param cnf 配置
     * @return 配置
     */
    @ApiOperation("更新配置")
    @PostMapping("/update")
    public R<CorrectCnf> update(@RequestBody @Validated CorrectCnf cnf) {
        AppHelper.projectSpace().saveCorrectCnf(cnf);
        return R.data(AppHelper.projectSpace().getCorrectCnf());
    }

}
